clear
set more off
log using log_file_Jain_Kapoor_REStat.smcl, replace
/* This Stata .do file contains code to analyze the raw data. Specifically the following steps are executed. */
/* 1. Transform and scale basic explanatory variables */
/* 2. Generate variables characterizing study groups, sections, roommates and quads */
/* 3. Generate variables for geographically close study group members */
/* 4. Generate variables for heterogeneity in peer characteristics */

use Peers_Dataset.dta
/* Year fixed effects */
gen y2008=0
replace y2008 =1 if year==2008
gen y2009=0
replace y2009 =1 if year==2009
gen y2010=0
replace y2010 =1 if year==2010
gen y2011=0
replace y2011 =1 if year==2011

/* Groupwork component of course variables */
egen high_grpwork_gpa = rowmean(grade_cstr grade_mktg grade_inva grade_dmop grade_mkdm grade_entr grade_opmg) if year==2008
egen high_grpwork_gpa2 = rowmean(grade_mgec grade_cstr grade_mktg grade_inva grade_dmop grade_mkdm grade_entr grade_opmg) if year==2009
egen high_grpwork_gpa3 = rowmean(grade_mgec grade_cstr grade_sait grade_dmop grade_mkdm grade_entr grade_opmg grade_gsb) if year==2010
egen high_grpwork_gpa4 = rowmean(grade_mgec grade_cstr grade_mkdm grade_dmop grade_entr grade_opmg grade_sait) if year==2011
replace high_grpwork_gpa = high_grpwork_gpa2 if year == 2009
replace high_grpwork_gpa = high_grpwork_gpa3 if year == 2010
replace high_grpwork_gpa = high_grpwork_gpa4 if year == 2011

egen med_grpwork_gpa = rowmean(grade_madm grade_gsb grade_fadm grade_mgto) if year==2008
egen med_grpwork_gpa2 = rowmean(grade_cfin grade_madm grade_fadm grade_mgto) if year==2009
egen med_grpwork_gpa3 = rowmean(grade_glec grade_cfin grade_mgto grade_fadm grade_mktg grade_gsb grade_sait) if year==2010
egen med_grpwork_gpa4 = rowmean(grade_fadm grade_glec grade_cfin grade_mgec grade_mktg grade_mgto) if year==2011
replace med_grpwork_gpa = med_grpwork_gpa2 if year == 2009
replace med_grpwork_gpa = med_grpwork_gpa3 if year == 2010
replace med_grpwork_gpa = med_grpwork_gpa4 if year == 2011

egen low_grpwork_gpa = rowmean(grade_smmd grade_glec grade_inva grade_sait grade_mgec grade_cfin) if year==2008
egen low_grpwork_gpa2 = rowmean(grade_smmd grade_glec grade_inva grade_sait grade_gsb) if year==2009
egen low_grpwork_gpa3 = rowmean(grade_smmd grade_mgec grade_inva grade_madm grade_cfin) if year==2010
egen low_grpwork_gpa4 = rowmean(grade_smmd grade_madm grade_inva grade_cfin grade_gsb) if year==2011
replace low_grpwork_gpa = low_grpwork_gpa2 if year == 2009
replace low_grpwork_gpa = low_grpwork_gpa3 if year == 2010
replace low_grpwork_gpa = low_grpwork_gpa4 if year == 2011
drop high_grpwork_gpa2 high_grpwork_gpa3 high_grpwork_gpa4 med_grpwork_gpa2 med_grpwork_gpa3 med_grpwork_gpa4 low_grpwork_gpa2 low_grpwork_gpa3 low_grpwork_gpa4

replace gmat=gmat/100replace offer_value= ln(offer_value)replace preinc = preinc/100000
gen studio = 0 if housing_type=="shared"
replace studio = 1 if housing_type=="studio"
/* Create study group variables */sort groupby group : gen group_size = _Nby group: egen core_gpa_grp = mean(core_gpa)replace core_gpa_grp = ((core_gpa_grp*group_size)-core_gpa)/(group_size-1)by group: egen totalexpft_grp = mean(totalexpft)replace totalexpft_grp= ((totalexpft_grp*group_size)-totalexpft)/(group_size-1)by group: egen female_grp = mean(female)replace female_grp= ((female_grp*group_size)-female)/(group_size-1)by group: egen single_grp = mean(single)replace single_grp= ((single_grp*group_size)-single)/(group_size-1)by group: egen gmat_grp = mean(gmat)replace gmat_grp= ((gmat_grp*group_size)-gmat)/(group_size-1)by group: egen IIT_grp = mean(IIT)replace IIT_grp= ((IIT_grp*group_size)-IIT)/(group_size-1)by group: egen DelhiU_grp = mean(DelhiU)replace DelhiU_grp= ((DelhiU_grp*group_size)-DelhiU)/(group_size-1)by group: egen citizen_India_grp= mean(citizen_India)replace citizen_India_grp= ((citizen_India_grp*group_size)-citizen_India)/(group_size-1)by group: egen preinc_grp= mean(preinc)replace preinc_grp= ((preinc_grp*group_size)-preinc)/(group_size-1)by group: egen age_grp= mean(age)replace age_grp= ((age_grp*group_size)-age)/(group_size-1)by group: egen totalexpft_grpsd= sd(totalexpft)gen totalexpft_var = totalexpft_grpsd*totalexpft_grpsdby group: egen gmat_grpsd= sd(gmat)gen gmat_var = gmat_grpsd*gmat_grpsdby group: egen preinc_grpsd= sd(preinc)gen preinc_var = preinc_grpsd*preinc_grpsdby group: egen age_grpsd= sd(age)gen age_var = age_grpsd*age_grpsd
/* Create section variables */sort sectionby section: gen section_size = _Nby section: egen core_gpa_section = mean(core_gpa)replace core_gpa_section= ((core_gpa_section*section_size)-core_gpa)/(section_size-1)by section: egen totalexpft_section = mean(totalexpft)replace totalexpft_section= ((totalexpft_section*section_size)-totalexpft)/(section_size-1)by section: egen female_section= mean(female)replace female_section= ((female_section*section_size)-female)/(section_size-1)by section: egen single_section= mean(single)replace single_section= ((single_section*section_size)-single)/(section_size-1)by section: egen gmat_section= mean(gmat)replace gmat_section= ((gmat_section*section_size)-gmat)/(section_size-1)by section: egen IIT_section= mean(IIT)replace IIT_section= ((IIT_section*section_size)-IIT)/(section_size-1)by section: egen DelhiU_section= mean(DelhiU)replace DelhiU_section= ((DelhiU_section*section_size)-DelhiU)/(section_size-1)by section: egen citizen_India_section= mean(citizen_India)replace citizen_India_section= ((citizen_India_section*section_size)-citizen_India)/(section_size-1)by section: egen preinc_section= mean(preinc)replace preinc_section= ((preinc_section*section_size)-preinc)/(section_size-1)by section: egen age_section= mean(age)replace age_section= ((age_section*section_size)-age)/(section_size-1)by section: egen totalexpft_sectionsd= sd(totalexpft)gen totalexpft_secvar = totalexpft_sectionsd*totalexpft_sectionsdby section: egen gmat_sectionsd= sd(gmat)gen gmat_secvar = gmat_sectionsd*gmat_sectionsdby section: egen preinc_sectionsd= sd(preinc)gen preinc_secvar = preinc_sectionsd*preinc_sectionsdby section: egen age_sectionsd= sd(age)gen age_secvar = age_sectionsd*age_sectionsd/* Create roommate variables */sort housing_groupby housing_group : gen housing_size =_Nby housing_group: egen core_gpa_room = mean(core_gpa)replace core_gpa_room = ((core_gpa_room*housing_size)-core_gpa)/(housing_size-1)by housing_group: egen totalexpft_room = mean(totalexpft)replace totalexpft_room = ((totalexpft_room*housing_size)-totalexpft)/(housing_size-1)by housing_group: egen female_room = mean(female)replace female_room = ((female_room*housing_size)-female)/(housing_size-1)by housing_group: egen single_room = mean(single)replace single_room = ((single_room*housing_size)-single)/(housing_size-1)by housing_group: egen gmat_room = mean(gmat)replace gmat_room = ((gmat_room*housing_size)-gmat)/(housing_size-1)by housing_group: egen IIT_room = mean(IIT)replace IIT_room = ((IIT_room*housing_size)-IIT)/(housing_size-1)by housing_group: egen DelhiU_room = mean(DelhiU)replace DelhiU_room = ((DelhiU_room*housing_size)-DelhiU)/(housing_size-1)by housing_group: egen citizen_India_room = mean(citizen_India)replace citizen_India_room = ((citizen_India_room*housing_size)-citizen_India)/(housing_size-1)by housing_group: egen preinc_room = mean(preinc)replace preinc_room = ((preinc_room*housing_size)-preinc)/(housing_size-1)by housing_group: egen age_room = mean(age)replace age_room = ((age_room*housing_size)-age)/(housing_size-1)gen gmatsq_room = gmat_room*gmat_roomby housing_group: egen core_gpa_roomsd= sd(core_gpa)gen core_gpa_roomvar = core_gpa_roomsd*core_gpa_roomsdby housing_group: egen totalexpft_roomsd= sd(totalexpft)gen totalexpft_roomvar = totalexpft_roomsd*totalexpft_roomsdby housing_group: egen gmat_roomsd= sd(gmat)gen gmat_roomvar = gmat_roomsd*gmat_roomsdby housing_group: egen preinc_roomsd= sd(preinc)gen preinc_roomvar = preinc_roomsd*preinc_roomsdby housing_group: egen age_roomsd= sd(age)gen age_roomvar = age_roomsd*age_roomsd
drop if Admissions==./* Create block peer variables */sort blockby block: gen block_size = _Nby block: egen core_gpa_block= mean(core_gpa)replace core_gpa_block= ((core_gpa_block*block_size)-core_gpa)/(block_size-1)by block: egen totalexpft_block= mean(totalexpft)replace totalexpft_block= ((totalexpft_block*block_size)-totalexpft)/(block_size-1)by block: egen female_block= mean(female)replace female_block= ((female_block*block_size)-female)/(block_size-1)by block: egen single_block= mean(single)replace single_block= ((single_block*block_size)-single)/(block_size-1)by block: egen gmat_block= mean(gmat)replace gmat_block= ((gmat_block*block_size)-gmat)/(block_size-1)by block: egen IIT_block= mean(IIT)replace IIT_block= ((IIT_block*block_size)-IIT)/(block_size-1)by block: egen DelhiU_block= mean(DelhiU)replace DelhiU_block= ((DelhiU_block*block_size)-DelhiU)/(block_size-1)by block: egen citizen_India_block= mean(citizen_India)replace citizen_India_block= ((citizen_India_block*block_size)-citizen_India)/(block_size-1)by block: egen preinc_block= mean(preinc)replace preinc_block= ((preinc_block*block_size)-preinc)/(block_size-1)by block: egen age_block= mean(age)replace age_block= ((age_block*block_size)-age)/(block_size-1)gen gmatsq_block= gmat_block*gmat_blockby block: egen core_gpa_blocksd= sd(core_gpa)gen core_gpa_blockvar = core_gpa_blocksd*core_gpa_blocksdby block: egen totalexpft_blocksd= sd(totalexpft)gen totalexpft_blockvar = totalexpft_blocksd*totalexpft_blocksdby block: egen gmat_blocksd= sd(gmat)gen gmat_blockvar = gmat_blocksd*gmat_blocksdby block: egen preinc_blocksd= sd(preinc)gen preinc_blockvar = preinc_blocksd*preinc_blocksdby block: egen age_blocksd= sd(age)gen age_blockvar = age_blocksd*age_blocksd/* Same Group and SV */gen underscore = "_"egen group_sv = concat(group underscore sv)sort group_svby group_sv: gen group_sv_size = _Ngen gmat_grp_same_sv = gmat_grp * group_sv_sizegen preinc_grp_same_sv = preinc_grp * group_sv_sizegen totalexpft_grp_same_sv =totalexpft_grp* group_sv_size gen age_grp_same_sv =age_grp* group_sv_sizegen female_grp_same_sv = female_grp* group_sv_sizegen single_grp_same_sv = single_grp* group_sv_sizegen citizen_India_grp_same_sv = citizen_India* group_sv_sizegen gmat_var_same_sv = gmat_var * group_sv_sizegen preinc_var_same_sv = preinc_var * group_sv_sizegen totalexpft_var_same_sv =totalexpft_var* group_sv_sizegen age_var_same_sv =age_var* group_sv_size/* Heterogeneity variables */
gen gmat_gtmean=0
replace gmat_gtmean =1 if gmat>=gmat_grp

gen gmat_roomgtmean=0
replace gmat_roomgtmean =1 if gmat>=gmat_room

/* Estimation *//* Table 1: Summary statistics*/sum gmat totalexpft preinc masters offer_value IIT DelhiU age single female citizen_India /* Table 2: Allocation to single apartments */
reg studio gmat totalexpft preinc masters age single female citizen_India y2009 y2010 y2011
probit studio gmat totalexpft preinc masters age single female citizen_India y2009 y2010 y2011

/* Table 3: Randomization check in study group and roommate assignment */reg gmat gmat_grp preinc_grp totalexpft_grp age_grp single_grp citizen_India_grp gmat_room preinc_room totalexpft_room age_room single_room citizen_India_room y2009 y2010 y2011 if female==1reg gmat gmat_grp preinc_grp totalexpft_grp age_grp single_grp citizen_India_grp gmat_room preinc_room totalexpft_room age_room single_room citizen_India_room y2009 y2010 y2011 if female==0reg preinc gmat_grp preinc_grp totalexpft_grp age_grp single_grp citizen_India_grp gmat_room preinc_room totalexpft_room age_room single_room citizen_India_room y2009 y2010 y2011 if female==1reg preinc gmat_grp preinc_grp totalexpft_grp age_grp single_grp citizen_India_grp gmat_room preinc_room totalexpft_room age_room single_room citizen_India_room y2009 y2010 y2011 if female==0
/* Table 4: Impact of own and peer characteristics on core terms GPA */
reg core_gpa gmat preinc totalexpft age female single citizen_India 																																																																						y2008 y2009 y2010 if housing_type=="shared"
reg core_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var 																																							y2008 y2009 y2010 if housing_type=="shared"
reg core_gpa gmat preinc totalexpft age female single citizen_India 																																gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar	y2008 y2009 y2010 if housing_type=="shared"
reg core_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var 	gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar 	y2008 y2009 y2010 if housing_type=="shared"

/* Table 6: Impact of study group and roommates GMAT scores by groupwork component in course */
reg high_grpwork_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"
reg med_grpwork_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"
reg low_grpwork_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"

/* Table 7: Heterogenous impact of peer GMAT scores */
reg core_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar y2008 y2009 y2010 if gmat_gtmean==0
reg core_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar y2008 y2009 y2010 if gmat_gtmean==1
reg core_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar y2008 y2009 y2010 if gmat_roomgtmean==0
reg core_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar y2008 y2009 y2010 if gmat_roomgtmean==1

/* Table B.1: Impact of core GPA on earnings */reg offer_value core_gpa elec_gpa gmat totalexpft preinc masters IIT DelhiU female single citizen_India age y2008 y2009 y2010/* Table C.2: Impact of geographically close study group members */
reg core_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_grp_same_sv preinc_grp_same_sv totalexpft_grp_same_sv gmat_var preinc_var totalexpft_var age_var gmat_var_same_sv preinc_var_same_sv totalexpft_var_same_sv gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"

/* Table D.1: Impact of extended networks */
reg core_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)
reg t1_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)
reg t2_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)
reg t3_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)
reg t4_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)

/* Table E.1: Impact of GMAT scores over terms */
reg t1_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"reg t2_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"reg t3_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"reg t4_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"/* Table E.2: Impact of peers on elective terms GPA */
reg elec_gpa gmat preinc totalexpft age female single citizen_India gmat_grp preinc_grp totalexpft_grp age_grp female_grp single_grp citizen_India_grp gmat_var preinc_var totalexpft_var age_var gmat_room preinc_room totalexpft_room age_room female_room single_room citizen_India_room gmat_roomvar preinc_roomvar totalexpft_roomvar age_roomvar y2008 y2009 y2010 if housing_type=="shared"/* Table 5: Randomized allocation of study groups and quads */drop group_size core_gpa_grp totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp DelhiU_grp IIT_grp totalexpft_var gmat_var preinc_var age_var totalexpft_grpsd gmat_grpsd preinc_grpsd age_grpsddrop section_size core_gpa_section totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section DelhiU_section IIT_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_sectionsd gmat_sectionsd preinc_sectionsd age_sectionsddrop housing_size core_gpa_room totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room DelhiU_room IIT_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_roomsd preinc_roomsd gmat_roomsd age_roomsd core_gpa_roomsd core_gpa_roomvardrop block_size core_gpa_block totalexpft_block female_block single_block gmat_block IIT_block DelhiU_block citizen_India_block preinc_block age_block core_gpa_blocksd core_gpa_blockvar totalexpft_blocksd totalexpft_blockvar gmat_blocksd gmat_blockvar preinc_blocksd preinc_blockvar age_blocksd age_blockvar shufflevar groupdrop grouprename group_shuffled groupshufflevar housing_groupdrop housing_grouprename housing_group_shuffled housing_group/* Study group variables */sort groupby group : gen group_size = _Nby group: egen core_gpa_grp = mean(core_gpa)replace core_gpa_grp = ((core_gpa_grp*group_size)-core_gpa)/(group_size-1)by group: egen totalexpft_grp = mean(totalexpft)replace totalexpft_grp= ((totalexpft_grp*group_size)-totalexpft)/(group_size-1)by group: egen female_grp = mean(female)replace female_grp= ((female_grp*group_size)-female)/(group_size-1)by group: egen single_grp = mean(single)replace single_grp= ((single_grp*group_size)-single)/(group_size-1)by group: egen gmat_grp = mean(gmat)replace gmat_grp= ((gmat_grp*group_size)-gmat)/(group_size-1)by group: egen IIT_grp = mean(IIT)replace IIT_grp= ((IIT_grp*group_size)-IIT)/(group_size-1)by group: egen DelhiU_grp = mean(DelhiU)replace DelhiU_grp= ((DelhiU_grp*group_size)-DelhiU)/(group_size-1)by group: egen citizen_India_grp= mean(citizen_India)replace citizen_India_grp= ((citizen_India_grp*group_size)-citizen_India)/(group_size-1)by group: egen preinc_grp= mean(preinc)replace preinc_grp= ((preinc_grp*group_size)-preinc)/(group_size-1)by group: egen age_grp= mean(age)replace age_grp= ((age_grp*group_size)-age)/(group_size-1)by group: egen totalexpft_grpsd= sd(totalexpft)gen totalexpft_var = totalexpft_grpsd*totalexpft_grpsdby group: egen gmat_grpsd= sd(gmat)gen gmat_var = gmat_grpsd*gmat_grpsdby group: egen preinc_grpsd= sd(preinc)gen preinc_var = preinc_grpsd*preinc_grpsdby group: egen age_grpsd= sd(age)gen age_var = age_grpsd*age_grpsd/* Section variables */sort sectionby section: gen section_size = _Nby section: egen core_gpa_section = mean(core_gpa)replace core_gpa_section= ((core_gpa_section*section_size)-core_gpa)/(section_size-1)by section: egen totalexpft_section = mean(totalexpft)replace totalexpft_section= ((totalexpft_section*section_size)-totalexpft)/(section_size-1)by section: egen female_section= mean(female)replace female_section= ((female_section*section_size)-female)/(section_size-1)by section: egen single_section= mean(single)replace single_section= ((single_section*section_size)-single)/(section_size-1)by section: egen gmat_section= mean(gmat)replace gmat_section= ((gmat_section*section_size)-gmat)/(section_size-1)by section: egen IIT_section= mean(IIT)replace IIT_section= ((IIT_section*section_size)-IIT)/(section_size-1)by section: egen DelhiU_section= mean(DelhiU)replace DelhiU_section= ((DelhiU_section*section_size)-DelhiU)/(section_size-1)by section: egen citizen_India_section= mean(citizen_India)replace citizen_India_section= ((citizen_India_section*section_size)-citizen_India)/(section_size-1)by section: egen preinc_section= mean(preinc)replace preinc_section= ((preinc_section*section_size)-preinc)/(section_size-1)by section: egen age_section= mean(age)replace age_section= ((age_section*section_size)-age)/(section_size-1)by section: egen totalexpft_sectionsd= sd(totalexpft)gen totalexpft_secvar = totalexpft_sectionsd*totalexpft_sectionsdby section: egen gmat_sectionsd= sd(gmat)gen gmat_secvar = gmat_sectionsd*gmat_sectionsdby section: egen preinc_sectionsd= sd(preinc)gen preinc_secvar = preinc_sectionsd*preinc_sectionsdby section: egen age_sectionsd= sd(age)gen age_secvar = age_sectionsd*age_sectionsd/* Rommmate variables */sort housing_groupby housing_group : gen housing_size = _Nby housing_group: egen core_gpa_room = mean(core_gpa)replace core_gpa_room = ((core_gpa_room*housing_size)-core_gpa)/(housing_size-1)by housing_group: egen totalexpft_room = mean(totalexpft)replace totalexpft_room = ((totalexpft_room*housing_size)-totalexpft)/(housing_size-1)by housing_group: egen female_room = mean(female)replace female_room = ((female_room*housing_size)-female)/(housing_size-1)by housing_group: egen single_room = mean(single)replace single_room = ((single_room*housing_size)-single)/(housing_size-1)by housing_group: egen gmat_room = mean(gmat)replace gmat_room = ((gmat_room*housing_size)-gmat)/(housing_size-1)by housing_group: egen IIT_room = mean(IIT)replace IIT_room = ((IIT_room*housing_size)-IIT)/(housing_size-1)by housing_group: egen DelhiU_room = mean(DelhiU)replace DelhiU_room = ((DelhiU_room*housing_size)-DelhiU)/(housing_size-1)by housing_group: egen citizen_India_room = mean(citizen_India)replace citizen_India_room = ((citizen_India_room*housing_size)-citizen_India)/(housing_size-1)by housing_group: egen preinc_room = mean(preinc)replace preinc_room = ((preinc_room*housing_size)-preinc)/(housing_size-1)by housing_group: egen age_room = mean(age)replace age_room = ((age_room*housing_size)-age)/(housing_size-1)by housing_group: egen core_gpa_roomsd= sd(core_gpa)gen core_gpa_roomvar = core_gpa_roomsd*core_gpa_roomsdby housing_group: egen totalexpft_roomsd= sd(totalexpft)gen totalexpft_roomvar = totalexpft_roomsd*totalexpft_roomsdby housing_group: egen gmat_roomsd= sd(gmat)gen gmat_roomvar = gmat_roomsd*gmat_roomsdby housing_group: egen preinc_roomsd= sd(preinc)gen preinc_roomvar = preinc_roomsd*preinc_roomsdby housing_group: egen age_roomsd= sd(age)gen age_roomvar = age_roomsd*age_roomsd/* Block peer variables*/sort blockby block: gen block_size = _Nby block: egen core_gpa_block= mean(core_gpa)replace core_gpa_block= ((core_gpa_block*block_size)-core_gpa)/(block_size-1)by block: egen totalexpft_block= mean(totalexpft)replace totalexpft_block= ((totalexpft_block*block_size)-totalexpft)/(block_size-1)by block: egen female_block= mean(female)replace female_block= ((female_block*block_size)-female)/(block_size-1)by block: egen single_block= mean(single)replace single_block= ((single_block*block_size)-single)/(block_size-1)by block: egen gmat_block= mean(gmat)replace gmat_block= ((gmat_block*block_size)-gmat)/(block_size-1)by block: egen IIT_block= mean(IIT)replace IIT_block= ((IIT_block*block_size)-IIT)/(block_size-1)by block: egen DelhiU_block= mean(DelhiU)replace DelhiU_block= ((DelhiU_block*block_size)-DelhiU)/(block_size-1)by block: egen citizen_India_block= mean(citizen_India)replace citizen_India_block= ((citizen_India_block*block_size)-citizen_India)/(block_size-1)by block: egen preinc_block= mean(preinc)replace preinc_block= ((preinc_block*block_size)-preinc)/(block_size-1)by block: egen age_block= mean(age)replace age_block= ((age_block*block_size)-age)/(block_size-1)by block: egen core_gpa_blocksd= sd(core_gpa)gen core_gpa_blockvar = core_gpa_blocksd*core_gpa_blocksdby block: egen totalexpft_blocksd= sd(totalexpft)gen totalexpft_blockvar = totalexpft_blocksd*totalexpft_blocksdby block: egen gmat_blocksd= sd(gmat)gen gmat_blockvar = gmat_blocksd*gmat_blocksdby block: egen preinc_blocksd= sd(preinc)gen preinc_blockvar = preinc_blocksd*preinc_blocksdby block: egen age_blocksd= sd(age)gen age_blockvar = age_blocksd*age_blocksdreg core_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)reg t1_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)reg t2_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)reg t3_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)reg t4_gpa totalexpft female single gmat citizen_India preinc age totalexpft_grp female_grp single_grp gmat_grp citizen_India_grp preinc_grp age_grp totalexpft_var gmat_var preinc_var age_var totalexpft_section female_section single_section gmat_section citizen_India_section preinc_section age_section totalexpft_secvar gmat_secvar preinc_secvar age_secvar totalexpft_room female_room single_room gmat_room citizen_India_room preinc_room age_room totalexpft_roomvar gmat_roomvar preinc_roomvar age_roomvar totalexpft_block female_block single_block gmat_block citizen_India_block preinc_block age_block totalexpft_blockvar gmat_blockvar preinc_blockvar age_blockvar y2008 y2009 y2010, vce (cluster sv)log closeclear
